/**
 * 
 */
var adminManagerController = function($scope, $location, $http,PaginatorRR,$log) {

	$scope.pageSize = 10;
	$scope.recordCount = [];
	$scope.search = [];
	$scope.showOperatorDetail = false;
	$scope.operator = "";
	$scope.showLoginIcon=false;

	var fetchFunction = function(currentPage, limit, propId, callback) {
		$http.get('../managerOrder/adminOrders', {
			params : {
				'pageSize' : limit,
				'pageNumber' : currentPage,
				'propId' : propId
			}
		}).success(callback);
	}
	$scope.search[1] = PaginatorRR(fetchFunction, $scope.pageSize, 1);
	
	$log.info($scope.search);
	
	$scope.getTab = function(propId) {
		$scope.search[propId] = PaginatorRR(fetchFunction, $scope.pageSize, propId);
	}

	/**
	 * 查看页面
	 */
	$scope.edit = function(obj) {

		if (obj.orderProp.id == 3) {
			obj.showOperator = true;

		} else {
			obj.showOperator = false;
		}

		$scope.norder = obj;
		$scope.showOperatorDetail = false;
		$scope.operator = "";
		$("#new_ui").offCanvas('open');
	}

	/**
	 * 关闭侧边栏
	 */
	$scope.closeNew = function() {

		$("#new_ui").offCanvas('close');
	}
	
	
	/** login cancel */
	$scope.cancel = function() {
		$('#my-prompt').modal("close");
	}
	$scope.login = function(phone, pwd) {
		var user = {
			'phone' : phone,
			'password' : pwd
		};

		$http({
			method : "post",
			url : '../../adminlogin',
			data : $.param(user), // pass in data
			headers : {
				'Content-Type' : 'application/x-www-form-urlencoded'
			}

		}).success(function(response) {
			
			if (response.code == 1) {
				sweetAlert("登录成功");
				$scope.showLoginIcon=true;
				$('#my-prompt').modal("close");
				$scope.search[1] = PaginatorRR(fetchFunction, $scope.pageSize, 1);
				$scope.search[7] = PaginatorRR(fetchFunction, $scope.pageSize, 7);
				$scope.search[8] = PaginatorRR(fetchFunction, $scope.pageSize, 8);
			} else if (response.code == 0) {
				sweetAlert("登录失败");
			}

		}).error();
	}

	$scope.showLogin = function() {
		$('#my-prompt').modal();
	}
	
	// 进入购物车
	$scope.shoppingCart = function() {

		$location.path("shopCart");
	}
	
	$scope.homePage=function(){
		$location.path("");
	}
}